<template>
  <!--
      	作者：luoyiming
      	时间：2020-06-25
      	描述：插件中心-砍价-活动列表-编辑砍价活动-其它
      -->
  <div>
    <div class="common-form">其它</div>

    <el-form-item label="购买条件">
      <el-radio-group v-model="form.conditions">
        <el-radio :label="1">砍到底价可购买</el-radio>
        <el-radio :label="0">砍价中可购买</el-radio>
      </el-radio-group>
      <div class="ml10 gray">
        <template v-if="form.conditions==1">只有砍到底价才可以购买</template>
        <template v-if="form.conditions==0">砍价中可购买是指不需要砍到底价就可以以当前价格下单购买</template>
      </div>
    </el-form-item>

    <el-form-item label="状态">
      <el-radio-group v-model="form.status">
        <el-radio :label="1">生效</el-radio>
        <el-radio :label="0">未生效</el-radio>
      </el-radio-group>
    </el-form-item>

    <el-form-item label="指定新用户">
      <el-radio-group v-model="form.is_new_user">
        <el-radio :label="0">否</el-radio>
        <el-radio :label="1">是</el-radio>
      </el-radio-group>
    </el-form-item>

    <el-form-item label="新用户评定标准" v-if="form.is_new_user == 1">
      <el-input v-model="form.reg_time" type="number" class="max-w460"></el-input>
      <div class="ml10 gray">(xxx 小时内注册的用户)</div>
    </el-form-item>

    <el-form-item label="分享标题">
      <el-input v-model="form.share_title" type="text" class="max-w460"></el-input>
      <div class="ml10 gray"></div>
    </el-form-item>


    <el-form-item label="分享图片：">
        <el-row>
          <el-button icon="el-icon-picture-outline" @click="openUpload">选择图片</el-button>
          <div v-if="form.share_img_id>0" class="img mt10">
            <img :src="form.share_img_url" width="100" height="100"/>
          </div>
        </el-row>
    </el-form-item>

    <el-form-item label="排序">
      <el-input v-model="form.sort" type="number" class="max-w460"></el-input>
      <div class="ml10 gray">(数值越大，活动排在越前面)</div>
    </el-form-item>

    
     <!--上传图片组件-->
     <Upload v-if="isupload" :isupload="isupload" @returnImgs="returnImgsFunc">上传图片</Upload>

  </div>
</template>

<script>
import Upload from '@/components/file/Upload';
export default {
  components: {
    /*选择商品组件*/
    Upload
  },
  data() {
    /*验证图片是否上传*/
    const validatorImages = (rule, value, callback) => {
      if (value < 1) {
        return callback(new Error('请上传分享图片'));
      } else {
        callback();
      }
    };

    return {
      /*是否上传图片*/
      isupload: false,
      /*图片是否上传了*/
      rulesImage: [{ validator: validatorImages, required: true, message: '请上传活动分享图片', trigger: 'change' }]
    };
  },
  inject: ['form'],
  methods: {
    /*上传*/
    openUpload(e) {
      this.isupload = true;
    },

    /*获取图片*/
    returnImgsFunc(e) {
      if (e != null && e.length > 0) {
        this.form.share_img_url = e[0].file_path;
        this.form.share_img_id = e[0].file_id;
      }
      this.isupload = false;
    }
  }
};
</script>

<style></style>
